import random

from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.keys import Keys
from selenium .webdriver.common.action_chains import ActionChains
# from elenium.webdriver.support.wait import WebDriverWait
# from  selenium.webdriver.support import Expected_conditions as EC

op = webdriver.ChromeOptions()
op.add_experimental_option("excludeSwitches", ["enable-automation"])
op.add_argument("--start-maximized")#浏览器最大化启动
op.add_experimental_option("useAutomationExtension", False)
driver = webdriver.Chrome(options = op)

driver.get(r"https://jqueryui.com/slider/#hotelrooms")

iframe = driver.find_element(By.CSS_SELECTOR,"#content > iframe")
driver.switch_to.frame(iframe)#进入iframe
# xl = driver.find_element(By.CSS_SELECTOR,"#minbeds")

# select_list = Select(xl)
# number = random.randint(0,5)
# select_list.select_by_index(number)
# print(number)
# sleep(1)
hd= driver.find_element(By.CSS_SELECTOR,"#slider > span")
number = random.randint(0,5)
print(number)
long =565*number/5
ActionChains(driver).drag_and_drop_by_offset(hd,long,0).perform()
sleep(2)

driver.quit()
